//
//  TermServiceViewController.m
//  BusinessApp
//
//  Created by macox on 16/10/6.
//  Copyright © 2016年 macox. All rights reserved.
//

#import "TermServiceViewController.h"
#import "TermTableViewCell.h"
#import "ServiceProvisionViewController.h"
@interface TermServiceViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *TermtebleView;
    TermTableViewCell *cell;
}
@end

@implementation TermServiceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [NNSingleton sharedSingleton].titlt_string = @"";
    self.navigationItem.title = @"服务条款";
    UIImage *classBackImage = [UIImage imageNamed:@"zuojiantou@3x-1"];
    classBackImage = [classBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:classBackImage style:UIBarButtonItemStylePlain target:self action:@selector(classBackAction)];
    self.view.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1.00];//    termCell
    [self createUI];
    // Do any additional setup after loading the view from its nib.
}
#pragma mark -- 返回
- (void)classBackAction{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
}
#pragma mark -- 创建视图
-(void)createUI{
    TermtebleView =  [[UITableView alloc]initWithFrame:CGRectMake(0, -5, kScrernWidth, 68 * 5 - 10) style:UITableViewStylePlain];
    TermtebleView.delegate = self;
    TermtebleView.dataSource = self;
        [TermtebleView  registerNib:[UINib nibWithNibName:@"TermTableViewCell" bundle:nil] forCellReuseIdentifier:@"termCell"];
      TermtebleView.scrollEnabled =NO;
    [self.view addSubview:TermtebleView];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%ld",(long)indexPath.section);
    
    if (indexPath.section == 0 && indexPath.row == 0) {
        [NNSingleton sharedSingleton].titlt_string = @"法律条款";
    }
    /*
     *入驻协议 单独接口
     */
    if (indexPath.section == 1 && indexPath.row == 0) {
        [NNSingleton sharedSingleton].titlt_string = @"入驻协议";        
    }
    if (indexPath.section == 2 && indexPath.row == 0) {
        [NNSingleton sharedSingleton].titlt_string = @"新手指南";
    }
    if (indexPath.section == 3 && indexPath.row == 0) {
        [NNSingleton sharedSingleton].titlt_string = @"提现规则";
    }

    ServiceProvisionViewController *service = [[ServiceProvisionViewController alloc]init];
    [self.navigationController pushViewController:service animated:YES];
   }
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 64;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 3;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    cell = [tableView dequeueReusableCellWithIdentifier:@"termCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.textLabel.textColor = [UIColor colorWithHue:0.00 saturation:0.00 brightness:0.28 alpha:1.00];
    cell.textLabel.font = [UIFont systemFontOfSize:15];
    if (0 == indexPath.section) {
        cell.contentLabel.text = @"法律条款";
    } else  if (1 == indexPath.section) {
        cell.contentLabel.text = @"入驻协议";

    }else  if (2 == indexPath.section) {
        cell.contentLabel.text = @"新手指南";

    }else  if (3 == indexPath.section) {
        cell.contentLabel.text = @"提现规则";

    }
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
